    <div class="table-tools">
        <a href="__URL__/addUI" class="btn btn-info" title="添加权限"><i class="fa fa-copy"></i> 添 加 </a>
        <!--<button type="submit" class="btn btn-primary" title="删除勾选的资源"><i class="glyphicon glyphicon-remove"></i> 删 除 </button>-->
        <!--<button type="button" class="btn btn-success" title="重新排序资源" onclick="sortQuestions()"><i class="fa fa-copy"></i> 重 排 </button>-->
        <form class="form-inline" method="post" action="__URL__/index" id="search_form"  role="form">
            <input type="hidden" name="pagenum" id="pagenum_hidden" value="{$page.pagenum}">
            <input type="hidden" name="count" value="{$recordcount}">
            <div class="form-group">
                <input type="text" name="id" value="{$id}" placeholder="请输入权限id">
                <input type="text" name="name" value="{$name}" placeholder="请输入权限名称">
                <button type="reset">清空</button>
                <button type="submit">搜索</button>
            </div>
        </form>
        <p>权限列表</p>
    </div>

    <table id="privileges-table" class="table table-striped table-hover table-condensed datatable">
        <thead>
            <tr id="privilege_{$privilege.id}">
                <th width="50px"> </th>
                <th>权限名</th>
                <th>URL</th>
                <th>是否显示</th>
                <th>父权限</th>
                <th width="150px">操作</th>
                <!--<th width="80px">排序</th>-->
            </tr>
        </thead>
        <tbody>
        	<volist name="privilegeList" id="privilege">
        		<tr>
        			<!--<td width="50px"><input name='id[]' type="checkbox" value="{$privilege.id}" /></td>-->
        			<td class="question-name">{$privilege.id}</td>
        			<td class="question-name">{$privilege.name}</td>
        			<td class="question-name">{$privilege.url}</td>
        			<td class="question-name">
                        <switch name="privilege.is_menu">
                            <case value="0">
                                不显示
                            </case>
                            <case value="1">
                                显示
                            </case>
                        </switch>
                    </td>
                    <td class="question-name">{$privilege.parent_name}</td>
        			<td width="150px">
                        <a href="__URL__/editUI/{$privilege.id}" class="btn btn-default btn-rounded btn-condensed btn-sm" title="编辑权限"><span class="fa fa-pencil">编辑</span>
                        </a>
                        <a onclick="deleteById('{$privilege.id}')" class="btn btn-default btn-rounded btn-condensed btn-sm" title="删除权限"><span class="glyphicon glyphicon-remove">删除</span></a>
                    </td>
        			<!--<td width="80px"><input name="sort[{$privilege.id}]" class="sort-input" type="text" value="{$privilege.sort}" /></td>-->
        		</tr>
        	</volist>
        </tbody>
    </table>
<nav style="float:right">
    <spen class="total">共 {$recordcount}条记录</spen>
    <div class="fr">
        <ul class="pagination">
            <eq name="page['pagenum']" value="1">
                <li class="disabled">
                    <else/>
                <li>
            </eq>
            <a href="#" onclick="gotoPage('1')">«</a></li>
            <foreach name="page.pagenums" item="vo">
                <eq name="page['pagenum']" value="$vo">
                    <li class="active"><a href="#">{$vo}</a></li>
                    <else/>
                    <li><a href="#" onclick="gotoPage('{$vo}')">{$vo}</a></li>
                </eq>
            </foreach>
            <eq name="page['pagenum']" value="$page.endPage">
                <li class="disabled">
                    <else/>
                <li>
            </eq>
            <a href="#" onclick="gotoPage('{$page.totalpage}')">»</a></li>
        </ul>
    </div>
</nav>
<div class="modal fade" id="my-alert" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
                <h4 class="modal-title" id="myModalLabel">提示</h4>
            </div>
            <div class="modal-body" id="hint_content">
            </div>
            <div class="modal-footer">
                <button type="button" id="close_btn" class="btn btn-default" data-dismiss="modal">关闭</button>
                <!--<button type="button" class="btn btn-primary">Save changes</button>-->
            </div>
        </div>
    </div>
</div>
    <div class="modal fade" id="delete_modal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
                    <h4 class="modal-title" >提示</h4>
                </div>
                <div class="modal-body" >
                    您确定删除该记录？
                </div>
                <div class="modal-footer">
                    <input type="hidden" name="id" id="privilege_id">
                    <button type="button"  class="btn btn-default" data-dismiss="modal">关闭</button>
                    <button type="button" onclick="doDelete()" class="btn btn-primary">删除</button>
                </div>
            </div>
        </div>
    </div>
<script>
    function gotoPage(pagenum) {
        //提交form
        $('#pagenum_hidden').val(pagenum);
        $('#search_form').submit();
    }
    function deleteById(id) {
        $('#privilege_id').val(id);
        $('#delete_modal').modal('show');
    }
    function doDelete(){
        $('#delete_modal').modal('toggle');
        var id = $("#privilege_id").val();
        if(id == ''){
            $("#hint_content").empty().append("请选择要删除的一项");
            $("#my-alert").modal('show');
            return;
        }
        $.ajax({
            type: "POST",
            url: '__URL__/delete',
            data:{id:id},
            dataType: "json",
            success: function (data) {
                $("#hint_content").empty().append(data.message);
                $("#my-alert").modal('show');
                if(data.check){
                    $("#privilege_id").val('');
                    $('#privilege_'+id).empty();
                }
            },
            error: function (data) {
                console.info(data);
                $("#hint_content").empty().append("请求超时！");
                $("#my-alert").modal('show');
            }
        });
    }
</script>